package net.m510.autosurfer.mhbk;

import java.net.URI;
import java.util.List;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentPostProcess;
import net.m510.autosurfer.core.Parameters;
import net.m510.autosurfer.core.utils.AnalyzeUtils;

import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

/**
 * @author mgoto
 *
 */
public class MhbkLoginInputUserNum extends DocumentPostProcess {
	private static final Logger log = Logger.getLogger(MhbkLoginInputUserNum.class.getName());

	private String userNum;
	
	public MhbkLoginInputUserNum() {
		this(null,null);
	}
	public MhbkLoginInputUserNum(CloseableHttpClient client, HttpClientContext context) {
		super(client, context);
		super.log = log;
	}
	@Override
	protected URI getUri(Document doc) {
		final String FORM_ID="LOGBNK_00000B";
		FormElement form = AnalyzeUtils.getFormElementByName(doc, FORM_ID);
		return AnalyzeUtils.resolveURIByFormAction(context, form);
	}
	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		Parameters p = Parameters.create(form);
		p.put("txbCustNo", this.userNum);
		return p.asNameValueList();
	}

	public String getUserNum() {
		return userNum;
	}
	public void setUserNum(String userNum) {
		this.userNum = userNum;
	}
}